package demo1;

class OuterClass {
    public int data1 = 10;
    private int data2 = 20;
    public static int data3 = 30;


    class InnerClass {
        public int data1 = 1111;

        public int data4 = 40;
        private int data5 = 50;
        public static final int data6 = 60;//final修饰的常量 常量是在编译的时候就已经确定了

        public void testInner() {
            System.out.println("testInner");
            //实例内部类 是存在外部类的this的
            System.out.println(OuterClass.this.data1);
            System.out.println(this.data1);
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }
    }

    public void testOuter() {
        InnerClass innerClass = new InnerClass();
        System.out.println(innerClass.data1);
    }

}

public class Test {
    public static void main(String[] args) {
        OuterClass outerClass = new OuterClass();
        OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        //OuterClass.InnerClass innerClass2 =  new OuterClass().new InnerClass();
        innerClass.testInner();
        outerClass.testOuter();
    }
}